package com.example.zz.example.pattern.builder;

import java.io.File;

/**
 * @author: zhuozhang6
 * @date: 2022/1/10
 * @email: zhuozhang6@iflytek.com
 * @Description: 建造者模式简单案例，这里是做的一个文件查找的建造者
 * 通过建造者收集参数，
 */
public class FileSearch {
    private String mName;
    private int mAge;
    private String mSex;

    public FileSearch(String name, int age, String sex) {
        mName = name;
        mAge = age;
        mSex = sex;
    }

    public File start() {
        //开始查找逻辑
        File file = findTheFile(mName, mAge, mSex);
        return file;
    }

    private File findTheFile(String mName, int mAge, String mSex) {
        return null;
    }


    public static class SearchBuilder {
        private String mName;
        private int mAge;
        private String mSex;

        public SearchBuilder() {

        }

        public SearchBuilder setFileName(String name) {
            mName = name;
            return this;
        }

        public SearchBuilder setAge(int i) {
            mAge = i;
            return this;
        }

        public SearchBuilder setSex(String sex) {
            mSex = sex;
            return this;
        }

        public FileSearch build() {
            return new FileSearch(mName, mAge, mSex);
        }
    }
}
